package com.kiven.swing;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import com.kiven.swing.SwingConsole;

public class DialogTest extends JFrame {
	private static String[] ids = {"one","two","three","four","five"};
	
	public DialogTest() {
		JPanel jp = new JPanel();
		jp.setLayout(new FlowLayout());
		
		for (String id : ids) {
			JButton b = new JButton(id);
			
			if ("one".equals(id)) {
				b.addActionListener(new ActionListener() {
					@Override
					public void actionPerformed(ActionEvent e) {
						JDialog d = new JDialog();
						d.setVisible(true);
					}
				});
			} else if ("two".equals(id)) {
				b.addActionListener(new ActionListener() {
					@Override
					public void actionPerformed(ActionEvent e) {
						String inputStr = JOptionPane.showInputDialog("Hloooowefnwofnwoenf","Hello");
//						System.out.println(inputStr);
					}
				});
			} 
			
			jp.add(b);
		}
		this.add(jp);
	}
	
	public static void main(String[] args) {
		SwingConsole.run(new DialogTest(), 400, 500);

	}

}
